package com.jcl.recruit.resume.mapper;

import com.jcl.recruit.mapper.SqlMapper;
import com.jcl.recruit.resume.model.ResumeJobIntention;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author liuyy
 * @date 2018/11/17
 */
public interface ResumeJobIntentionMapper extends SqlMapper {

    String TABLE_NAME = " resume_job_intention ";
    String SQL_INSERT_SUFFIX_ENTITY = "(resume_id, corp_code, expect_job, expect_pay, expect_pay_start, expect_pay_end," +
            " work_place, work_industry, work_nature, entry_date, keyword) ";
    String SQL_INSERT_SUFFIX_ENTITY_VALUES = "(#{resumeId},#{corpCode},#{expectJob},#{expectPay}," +
            "#{expectPayStart},#{expectPayEnd}, #{workPlace}, #{workIndustry},#{workNature}, #{entryDate}, #{keyword})";

    @Select({
            QUERY_SCRIPT_START,
            SQL_QUERY_RESUME_ID,
            SQL_IN,
            FOREACH_START_LIST_RESUME_IDS,
            SQL_PROPERTY_RESUME_ID_VALUE,
            FOREACH_END,
            SQL_AND,
            SQL_CORP_CODE,
            QUERY_SCRIPT_END
    })
    List<ResumeJobIntention> findListByResumeIds(@Param("corpCode") String corpCode, @Param("resumeIds") List<Integer> resumeIds);

    @Select({
            QUERY_SCRIPT_START,
            SQL_QUERY_RESUME_ID,
            SQL_EQUAL,
            SQL_PROPERTY_RESUME_ID_VALUE,
            SQL_AND,
            SQL_CORP_CODE,
            QUERY_SCRIPT_END
    })
    ResumeJobIntention findOne(@Param("corpCode") String corpCode, @Param("resumeId") Integer resumeId);

    @Select({
            QUERY_SCRIPT_START,
            SQL_QUERY_RESUME_ID,
            SQL_EQUAL,
            SQL_PROPERTY_RESUME_ID_VALUE,
            SQL_AND,
            SQL_CORP_CODE,
            QUERY_SCRIPT_END
    })
    Map<String, Object> findOneMap(@Param("corpCode") String corpCode, @Param("resumeId") Integer resumeId);

    @Insert({
            QUERY_SCRIPT_START,
            SQL_INSERT,
            SQL_INSERT_VALUE,
            SQL_INSERT_SUFFIX_ENTITY_VALUES,
            QUERY_SCRIPT_END
    })
    int add(ResumeJobIntention entity);

    @Delete({
            QUERY_SCRIPT_START,
            SQL_DELETE_RESUME_ID,
            SQL_IN,
            FOREACH_START_LIST_RESUME_IDS,
            SQL_PROPERTY_RESUME_ID_VALUE,
            FOREACH_END,
            SQL_AND,
            SQL_CORP_CODE,
            QUERY_SCRIPT_END
    })
    int batchDeleteByResumeIds(@Param("corpCode") String corpCode, @Param("resumeIds") List<Integer> resumeIds);

    String SQL_INSERT = "insert into " + TABLE_NAME + SQL_INSERT_SUFFIX_ENTITY;
    String SQL_QUERY_RESUME_ID = "select * from " + TABLE_NAME + " where resume_id ";
    String SQL_DELETE_RESUME_ID = "delete from " + TABLE_NAME + " where resume_id ";

}
